#include <bits/stdc++.h>
// 2025/02/07
// tag:
// Author: Zhang Muen
using namespace std;
class State {
public:
    int64_t id, weight;
    State(int64_t i, int64_t w)
    {
        id = i;
        weight = w;
    }
};

struct cmp {
    bool operator()(State& a, State& b)
    {
        return a.weight > b.weight;
    }
};

int64_t n, m, k, e, dist[21], cost[101][101], dp[101];
vector<State> graph[21];
bool cantuse[21][101], can[21];

void Dijkstra(int64_t start)
{
    for (int i = 1; i <= m; i++)
        dist[i] = 1e9;
    priority_queue<State, vector<State>, cmp> pq;
    dist[start] = 0;
    pq.push(State(start, 0));
    while (!pq.empty()) {
        State state = pq.top();
        pq.pop();
        int64_t Dist = state.weight;
        if (Dist > dist[state.id])
            continue;
        for (auto neighbor : graph[state.id]) {
            if (can[neighbor.id])
                continue;
            int64_t Dist2 = Dist + neighbor.weight;
            if (dist[neighbor.id] > Dist2) {
                dist[neighbor.id] = Dist2;
                pq.push(State(neighbor.id, Dist2));
            }
        }
    }
}

void init(int x, int y){
    memset(can, 0, sizeof(can));
    for (int i = x; i <= y; i++)
        for (int j = 1; j <= m; j++) 
            if (cantuse[j][i])
                can[j] = true;
    Dijkstra(1);
    cost[x][y] = dist[m];
}

signed main()
{
    cin >> n >> m >> k >> e;
    for (int i = 1; i <= e; i++){
        int64_t u, v, w;
        cin >> u >> v >> w;
        graph[u].push_back(State(v, w));
        graph[v].push_back(State(u, w));
    }
    int64_t d;
    cin >> d;
    for (int i = 1; i <= d; i++) {
        int p, a, b;
        cin >> p >> a >> b;
        for (int j = a; j <= b; j++)
            cantuse[p][j] = true;
    }
    for (int i = 1; i <= n; i++) 
        for (int j = i; j <= n; j++) 
            init(i, j);
    memset(dp, 0x3f, sizeof(dp));
    for (int i = 1; i <= n; i++) {
        dp[i] = cost[1][i] * i;
        for (int j = i - 1; j >= 0; j--) {
            dp[i] = min(dp[i], dp[j] + cost[j + 1][i] * (i - j) + k);
        }
    }
    cout << dp[n] << endl;
    return 0;
}